//
//  HomeCell.swift
//  YueChat
//
//  Created by IMac on 2024/9/19.
//

import UIKit

class HomeCell: UITableViewCell {
    
    @IBOutlet weak var nickName: UILabel!
    @IBOutlet weak var nftImg: UIImageView!
    @IBOutlet weak var icon: UIImageView!
    @IBOutlet weak var contentLab: UILabel!
    @IBOutlet weak var timeLab: UILabel!
    @IBOutlet weak var silentImg: UIImageView!
    @IBOutlet weak var redImg: UIImageView!
    @IBOutlet weak var msgRead: UILabel!
    var userInfo = DMCCUser()
    var group = DMCCGroup()
    var serverNotCount = Int()
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.msgRead.layer.masksToBounds = true
        self.msgRead.layer.cornerRadius = 10
    }
    
    func setUserInfo(userInfo: DMCCUser) {
        self.userInfo = userInfo

        icon.sd_setImage(with: URL(string: userInfo.portrait), placeholderImage: kUserImage)
//        let alias = userInfo.alias // 或者使用 [[DMCCIMService getInstance] getFriendAlias:userInfo.userId]
        if !userInfo.getAlias().isEmpty {
            nickName.text = userInfo.getAlias()
        }
        
        let nftStr = userInfo.getNft() // 或者使用 [UserInfoInfo getNft:userInfo.describes]
        if !nftStr!.isEmpty {
            nftImg.isHidden = false
        } else {
            nftImg.isHidden = true
        }
    }
    
    func setGroup(group:DMCCGroup) {
        self.group = group
        nftImg.isHidden = true
        nickName.text = group.name
        icon.sd_setImage(with: URL(string: group.portrait), placeholderImage: kGroupImage)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
